export interface Node {
    id: string;
    elID: string;
    left: number;
    top: number;
    flip: boolean;
    type: string;
    params: Param[];
    inputPorts: string[];
    outputPorts: string[];
}

export interface Edge {
    id: string,
    srcEndpointID: string,
    destEndpointID: string,
    srcNode: string,
    destNode: string,
    midpoints: Midpoint[]
}

export interface Port {
    nodeID: string,
    nodeElID: string,
    direction: string, // 'input' or 'output'
    endpointID: string, // a number
}

export interface Param {
    name: string,
    value: any
}

export interface ParamScheme {
    name: string,
    type: string,
    required: boolean
}

export interface Args {
    name: string,
    type: string
}

// Card是Node的骨架。
export interface Card {
    id: string,
    title: string,
    category: "internal" | "custom" | "external"
    description: string,
    params: ParamScheme[],
    inputs: Args[],
    outputs: Args[],
    appearance: Appearance,
    inputVariable: boolean,
    outputVariable: boolean
}

export interface Chart {
    edges: Edge[],
    nodes: Node[]
}

export interface Midpoint {
    left: number,
    top: number,
    index: number,
    edgeID: string
}

export interface Appearance {
    type: 'triangle' | 'rect'
    figureMode: 'latex' | 'icon' | 'none'
    source: string,
    xScale?: number,
    yScale?: number
}

// 适用于Route的参数
export interface RoutePort {
    name: string,
    type: "input" | "output",
    // id: string,
    connectedNode: string
    connectedPort: string
    // port: string
}
export interface FlowchartJSON {
    nodes: Node[]
    edges: Edge[]
    info: Info
}


export interface Info {
    name: string
    type: "main" | "route"

    settings: RouteSettings | MainGraphSettings
}

export interface GraphSettings {

}

export interface MainGraphSettings extends GraphSettings {

}

export interface RouteSettings extends GraphSettings {
    inPorts: RoutePort[]
    outPorts: RoutePort[]
}

export interface ChartMeta {
    chartType: 'main' | 'route' | "",
    label: string,
    fileName: string
}

export interface ProjectMeta {
    path: string,
    name: string
}

export interface SimulationConfig {
    [key: string]: number | string | boolean
}

export interface LogRow {
    type: "stdout" | "stderr",
    content: string
}